import { EnumUserType } from '../utils/constant.js'

Component({
  data: {
    selected: 0,
    color: "#626262",
    selectedColor: "#41d6bd",
    list: [{
      pagePath: "/pages/index/index",
      iconPath: "/img/tab/1-1.png",
      selectedIconPath: "/img/tab/1.png",
      text: "首页"
    },{
      pagePath: "/pages/work/work",
      iconPath: "/img/tab/2-1.png",
      selectedIconPath: "/img/tab/2.png",
      text: "职位"
    },{
      pagePath: "/pages/news/news",
      iconPath: "/img/tab/3-1.png",
      selectedIconPath: "/img/tab/3.png",
      text: "资讯",
    },
    {
      pagePath: "/pages/my/my",
      iconPath: "/img/tab/4-1.png",
      selectedIconPath: "/img/tab/4.png",
      text: "我的",
    }
  ]
  },
  attached() {
    let userType = wx.getStorageSync('userType')
    if(userType == EnumUserType.QiYe){
      this.data.list[1] = {
        pagePath: "/pages/rencai/rencai",
        iconPath: "/img/tab/2-1.png",
        selectedIconPath: "/img/tab/2.png",
        text: "人才"
      }
    }

    this.setData({
      list: this.data.list
    })
  },
  methods: {
    switchTab(e) {
      let { path, index } = e.currentTarget.dataset
      wx.switchTab({url: path})
      this.setData({
        selected: index
      })
    }
  }
})